package com.example.myapplication3.image.bean;

import android.net.Uri;

/**
 * 图片项实体类
 *
 * @author yuanc
 * @Description: (用一句话描述)
 * @date 2025/8/9 19:36
 */
public class ImageItem {
    private long id;            // 图像ID
    private String name;        // 图像名称
    private String path;        // 图像路径
    private Uri uri;            // 图像URI
    private long size;          // 文件大小(字节)
    private long dateAdded;     // 添加日期(秒)
    private long dateModified;  // 修改日期(秒)
    private String mimeType;    // MIME类型
    private int width;          // 宽度(像素)
    private int height;         // 高度(像素)

    public ImageItem(long id, String name, String path, Uri uri, long size, long dateAdded, long dateModified, String mimeType, int width, int height) {
        this.id = id;
        this.name = name;
        this.path = path;
        this.uri = uri;
        this.size = size;
        this.dateAdded = dateAdded;
        this.dateModified = dateModified;
        this.mimeType = mimeType;
        this.width = width;
        this.height = height;
    }

    public long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getPath() {
        return path;
    }

    public Uri getUri() {
        return uri;
    }

    public long getSize() {
        return size;
    }

    public long getDateAdded() {
        return dateAdded;
    }

    public long getDateModified() {
        return dateModified;
    }

    public String getMimeType() {
        return mimeType;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    /**
     * 获取格式化后的文件大小
     */
    public String getFormattedSize() {
        if (size <= 0) return "0 B";

        final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
        int digitGroups = (int) (Math.log10(size) / Math.log10(1024));

        return String.format("%.1f %s", size / Math.pow(1024, digitGroups), units[digitGroups]);
    }

    /**
     * 获取格式化后的日期
     */
    public String getFormattedDate() {
        return android.text.format.DateFormat.format("yyyy-MM-dd HH:mm", dateAdded * 1000).toString();
    }

    /**
     * 获取图片分辨率信息
     */
    public String getResolutionInfo() {
        return width + "×" + height;
    }
}
